<ion-view view-title="账号 - {{theUser.username}}" show-tabs>
	<ion-nav-buttons side="right">
    	<button class="button" ng-class="{'button-icon ion-ios-compose-outline':!$root.isEdit,'button-clear':$root.isEdit}" ng-click="$root.toggleEdit();"><span ng-if="$root.isEdit">取消</span></button>
	</ion-nav-buttons>
    <ion-content class="wrap-light">

		<ion-list class="wrap-light2" ng-class="{'input-border-bottom':$root.isEdit}">
			<form name="userForm" ng-submit="$root.toggleEdit();update();" novalidate>
				<ion-item class="item-divider margin-top-large">
				    账号信息
				</ion-item>

				<ion-item class="item-base item-icon-left">
				    <i class="icon ion-log-in dark2"></i>
				    <span class="list-label text-left">账号</span>
				    <span>{{theUser.username}}</span>
				</ion-item>

				<ion-item class="item-input item-icon-left">
				    <i class="icon ion-email dark2"></i>
				    <span class="list-label text-left">邮箱</span>
				    <input type="email" name="email" maxlength="30" placeholder="工作邮箱" ng-readonly="!$root.isEdit" ng-model="theUser.emails[0].address" auto-focus>
				</ion-item>

				<ion-item class="item-base item-icon-left">
					<span class="list-label text-left">所属部门</span>
					<span>{{theUser.profile.department}}</span>
				</ion-item>

				<ion-item class="item-base item-icon-left">
					<span class="list-label text-left">职能</span>
					<span>{{theUser.profile.roleName}}</span>
				</ion-item>

				<ion-item class="item-base item-select item-icon-left" ng-if="$root.isEdit">
					<span class="list-label text-left">账号状态</span>
					<select ng-if="$root.isEdit" ng-model='theUser.profile.state'>
						<option value="启用">启用</option>
						<option value="锁定">锁定 - 仍统计该账号</option>
						<option value="停用">停用 - 不再统计该账号</option>
					</select>
				</ion-item>
				<ion-item class="item-base item-icon-left" ng-if="!$root.isEdit">
					<span class="list-label text-left">账号状态</span>
					<span>{{theUser.profile.state}}</span>
				</ion-item>


				<button class="button button-block button-light" ng-click="resetPw()">
		            修改密码
		        </button>
		        <button class="button button-block button-balanced" ng-if="$root.isEdit" type="submit">保存</button>
			</form>

			<ion-item class="margin-top-large item-select item-icon-left item-button-right assertive" ng-if="!theEmployee">
			    <i class="icon ion-person dark2"></i>
			    尚未指定员工
			     <select ng-model="preBindedData.eid">
	            <option value="">请选择</option>
	            <option ng-repeat="employee in employees" value="{{employee._id}}">{{employee.name}}</option>
	          </select>
			</ion-item>
			<ion-item class="item item-button-right" ng-if="!theEmployee">
	          <span class="input-label">选择员工</span>

	          <button class="button button-balanced" ng-click="bind();">绑定</button>
	        </ion-item>


			<div ng-if="!$root.isEdit && theUser.profile.employee_id">
				<ion-item class="item-divider margin-top-large">
				    员工信息
				</ion-item>

				<ion-item class="item-icon-left item-icon-right" ng-if="theUser.profile.employee_id">
					<i class="icon ion-person dark2"></i>
				    <span class="list-label text-left">姓名</span>
				    <span>{{theEmployee.name}}</span>
				    <i class="icon dark2" ng-class="{'ion-male': theEmployee.sex=='男','ion-female': theEmployee.sex=='女'}"></i>
				</ion-item>
				<ion-item class="item-icon-left" ng-if="theUser.profile.employee_id && !$root.isEdit">
				    <i class="icon ion-android-wifi dark2"></i>
				    <span class="list-label text-left">状态</span>
				    <span ng-class="{'balanced':theEmployee.state=='在职'}">{{theEmployee.state}}</span>
				</ion-item>

				<ion-item ng-if="theUser.profile.employee_id">
					<div class="button-bar">
					  <a class="button balanced" ng-href="#/employee-{{theEmployee._id}}"><i class="icon ion-eye"></i> 查看</a>
					  <a class="button balanced" ng-click="call()"><i class="icon ion-ios-telephone-outline"></i> 拨号</a>
					  <a class="button balanced"><i class="icon ion-ios-chatboxes-outline"></i> 通知</a>
					</div>
				</ion-item>
			</div>


		</ion-list>
	</ion-content>
</ion-view>
